﻿@{
	Layout = null;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>职称设置</title>
	<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
</head>
<body>
	<script src="https://unpkg.com/vue@3"></script>
	<!-- 引入Element Plus -->
	<script src="https://unpkg.com/element-plus"></script>
	<!-- 引入axios -->
	<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	<div id="app">
		<span>
			您正在做的业务是：人力资源--客户化设置--人力资源档案管理设置--职称设置
		</span><p></p>
		<button style="float:right" v-on:click="addFirstKind">添加</button>
		<!-- 表格内容 -->
		<el-table :data="tableData" style="width: 100%">
			<!-- 表格列 -->
			<el-table-column prop="uId" label="用户编号" style="color: aquamarine;"></el-table-column>
			<el-table-column prop="uName" label="用户名称" style="color: aquamarine;"></el-table-column>
			<el-table-column prop="uTrueName" label="真实姓名" style="color: aquamarine;"></el-table-column>
			<el-table-column prop="uPassWord" label="用户密码" style="color: aquamarine;"></el-table-column>
			<el-table-column prop="uidentity" label="用户身份" style="color: aquamarine;"></el-table-column>
			<el-table-column label="操作">
				<!-- 自定义操作列 -->
				<template #default="{row}">
					<el-button link type="primary" size="small" v-on:click="updateClick(row)">修改</el-button>
					<el-button link type="primary" size="small" v-on:click="deleteClick(row)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>

	<script>
		const app = Vue.createApp({
			data() {
				return {
					showModal: false,
					upvis: false,
					formData: {
						uId: 0,
						uName: '',
						uTrueName: '',
						uPassWord: '',
						uidentity:''
					},
					tableData: []
				};
			},
			methods: {
				addFirstKind() {
					window.location.href = "/User/yhtj";//页面跳转
				},

				fetchData() {
					try {
						const vm = this;
						axios.get("/User/UserGet")
							.then(function (response) {
								console.log(response.data);
								vm.tableData = response.data;
							})
							.catch(function (error) {
								console.error(error);
							});
					} catch (error) {
						console.error(error);
					}
				},
				updateClick(row){
					sessionStorage.setItem('uId', JSON.stringify(row.uId || '[]'));//把值存到session中
					window.location.href = "/User/yhxg";//页面跳转
				},
				deleteClick(row) {
					if (confirm("确认删除吗?")) {
						const vm = this;
						axios.get("/User/UserDelete?UId=" + row.uId)
							.then(function (response) {
								if (response.data) {
									vm.fetchData();
									alert("删除成功");
								} else {
									alert("删除失败");
								}
							})
							.catch(function (error) {
								console.error(error);
								alert("请求失败");
							});
					}
				}
			},
			mounted() {
				this.fetchData();
			}
		});

		// 安装 Element Plus
		app.use(ElementPlus);

		// 挂载应用程序到页面上
		app.mount("#app");
	</script>
</body>
</html>
